home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / wx_lib10.zoo / wx_puts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-02  |  820 b   |  52 lines

  1. #include <wx_lib.h>
  2. #include <alloc.h>
  3.  
  4. int        wx_puts(ws,sp)
  5. Window    *ws;
  6. char    *sp;
  7. {
  8.     char    *mp,
  9.             *tp;
  10.  
  11.     if ((mp = malloc(strlen(sp))) == NULL) {
  12.         return FALSE;
  13.     } else {
  14.         strcpy(mp,sp);
  15.         /*
  16.          * tp is a temporary pointer.  It's what we're going to use to
  17.          * search for \t \n \r, etc. 
  18.          */
  19.         tp = sp = mp;
  20.         while (*tp) {
  21.             switch (*tp) {
  22.                 /*
  23.                  * We eat tabs in this routine
  24.                  */
  25.                 case '\t' :
  26.                     *tp = ' ';
  27.                     break;
  28.                 /*
  29.                  * If it's an end of line char
  30.                  */
  31.                 case '\r' :
  32.                     *tp = '\0';
  33.                     break;
  34.                 case '\n' :
  35.                     *tp = '\0';
  36.                     wx_outstr(ws,sp);
  37.                     ws->ypos++;
  38.                     ws->xpos = ws->minx;
  39.                     sp = ++tp;
  40.                     --tp;
  41.                     break;
  42.                 default :
  43.                     break;
  44.             }
  45.             tp++;
  46.         }
  47.         wx_outstr(ws,sp);
  48.         free(mp);
  49.     }
  50.     return TRUE;
  51. }
  52.